namespace Resharper.Abstractions.CodeDom.Expressions.ExpressionInitializers
{
  using JetBrains.ReSharper.Psi.CSharp.Tree;
  using Resharper.Abstractions.CodeDom.TreeNodes;

  /// <summary>Defines the <see cref="ExpressionInitializer"/> class.</summary>
  public class ExpressionInitializer : TreeNode
  {
    #region Constructors and Destructors

    /// <summary>Initializes a new instance of the <see cref="ExpressionInitializer"/> class.</summary>
    /// <param name="initializer">The initializer.</param>
    internal ExpressionInitializer(IExpressionInitializer initializer) : base(initializer)
    {
    }

    #endregion

    #region Properties

    /// <summary>
    /// Gets the value.
    /// </summary>
    public Expression Value
    {
      get
      {
        return ExpressionFactory.GetExpression(this.InternalInitializer.Value);
      }
      set
      {
        this.InternalInitializer.SetValue((ICSharpExpression)value.InternalExpression);
      }
    }

    /// <summary>The initializer field.</summary>
    internal IExpressionInitializer InternalInitializer
    {
      get
      {
        return (IExpressionInitializer)this.InternalTreeNode;
      }
    }

    #endregion
  }
}